<script src="<?php echo get_url('js/jquery.ajaxfileupload.js');?>" type="text/javascript"></script>
<script src="<?php echo get_url('js/checkpreviewimg.js');?>" type="text/javascript"></script>
<div class="index-container w1024 bc">
    <div class="doctor-form">
        <h1 class="f24 mt30 mb20 tc">医师申请表</h1>
        <div class="prev-title f14 pl20 pr10 clearfix"><span class="fl">请填写你的认证资料(医生资格证书)</span><span class="fr mr30">为何申请服务类型？</span></div>
        <p class="form-msg pl20 pr20 clearfix"><span class="fl">您的个人隐私信息均不会被公开，只用于认证医师资格及核实医生本人信息。</span><span class="fr">所填信息都会有51天使平台认证</span></p>
        <p class="form-msg pl20 pr20">请尽量填写完所有内容，加快申请审核进度。</p>
        <div class="status-box p20 clearfix">
            <div>
                <p class="mt10">
                    <label class="in_b">身&nbsp;&nbsp;份&nbsp;&nbsp;证</label>
                    <input type="text" value="<?php echo isset($response['doctors']['PersonId']) && $response['doctors']['PersonId'] ? $response['doctors']['PersonId'] :''?>" id="sign_id" name="sign_id"
                           class="input-01 ml10 mr10"  onmouseup="check_sign_id(this)" />
                    <span id="checksign_id"></span>
                </p>
                <p class="mt10">
                    <label class="in_b">出生日期</label>
                    <input type="text" value="<?php echo isset($response['doctors']['Birthday']) && $response['doctors']['Birthday'] ? $response['doctors']['Birthday'] :''?>" id="birthday" name="birthday" class="input-01 ml10 mr10" readonly/>
                </p>
                <div class="mt10 clearfix">
                    <label class="fl mt30">上传头像</label>
                    <p class="fl ml10">
                        <img id="src_head_img" src="<?php echo isset($response['doctors']['HeadImageId']) && $response['doctors']['HeadImageId'] ? '/center/doctors/show_img?id='.$response['doctors']['HeadImageId'].'&t='.rand(10,50) : get_theme_url('images/index-logo.png')?>" alt="头像图片" class="fl" width="100" height="100" />
                        <span class="f12 mt30 ml10 in_b">注：图片最大为xxM，将显示在网站上<br />建议上传个人头像</span>
                    </p>
                    <span id="checkuser_head_img"></span>
                </div>
                <p class="mt10">
                    <label class="in_b">&nbsp;</label>
<!--                    <a href="javascript:;" class="button-01 ml10">上传头像</a>-->
                    <img id="loading_head_img" src="<?php echo get_theme_url('images/loading.gif')?>" style="display:none;">
                    <input type="file" name="head_img" id="head_img">
                    <input type="button" value="上传头像" onclick="return upload_image('head_img',1);" >
                    <input type="hidden" value="<?php echo isset($response['doctors']['HeadImageId']) && $response['doctors']['HeadImageId'] ? $response['doctors']['HeadImageId'] :''?>" id="user_head_img" name="user_head_img"/>
                </p>
                <p class="mt10"><label class="in_b">医院名称</label>
                    <select name="hospital" id="hospital" class="input-01 ml10 mr10">
                        <option value="">--请选择--</option>
                        <?php if(isset($response['hospital']) && $response['hospital']):?>
                            <?php foreach($response['hospital'] as $hos):?>
                                <?php if(isset($response['app_first']) && isset($response['app_first']['CurrentDepartmentId']) && $response['app_first']['CurrentDepartmentId'] == $hos['HospitalId']):?>
                                    <?php $select = true;?>
                                <?php else:?>
                                    <?php $select = false;?>
                                <?php endif;?>
                                <option value="<?php echo $hos['HospitalId'] ?>" <?php if($select):?> selected="true" <?php endif;?>><?php echo $hos['Name'];?></option>
                            <?php endforeach;?>
                        <?php endif?>
                    </select>
                </p>
                <span id="checkhospital"></span>
            </div>
            <div class="msg">
                <p>所填信息都会有51天使平台认证</p>
                <p>其他个人资料如教育信息，个人介绍等可在认证完成后在个人中心的个人资料中完善。</p>
            </div>
        </div>
        <div class="mt20 tc">
            <input value="取消" type="button" class="button-01 mr20">
            <input value="下一步" type="button" class="button-01 mr20" onclick=" return first_submit()" >
        </div>
    </div>
</div>
<script>
    function first_submit() {
        var sign_id = $("#sign_id").val();
        var birthday = $("#birthday").val();
        var user_head_img = $("#user_head_img").val();
        var hospital = $("#hospital").val();
        if(sign_id == '') {
            $("#checksign_id").html('请填写身份证号');
            return false;
        }
        if(user_head_img == '') {
            $("#checkuser_head_img").html('请上传头像');
            return false;
        }
        if(hospital == '') {
            $("#checkhospital").html('请选择医院');
            return false;
        }
        //走到下一步
        var params = 'app_fmt=json&app_page=null&sign_id='+sign_id+'&birthday='+birthday+'&user_head_img='+user_head_img+'&hospital='+hospital;
        Ajax.call('/center/doctors/do_app_first', params, function (data) {
            data = eval('('+data+')');
            if(data.code ==0) {
                location.href='/center/doctors/app_md';
            }
        });
    }
    function check_sign_id(obj) {
        var sign_id = $(obj).val();
        var flag = checkCardId(sign_id);
        if(flag) {
            if (sign_id.length == 15) {
                tmpStr = sign_id.substring(6, 12);
                tmpStr = "19" + tmpStr;
                tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6);
            }
            else {
                tmpStr = sign_id.substring(6, 14);
                tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6);
            }
            $("#birthday").val(tmpStr);
        }
    }
</script>